<?php
class Chanel_ListController extends Zendvn_Controller_Action{
	
	public function init()
	{
		parent::init();
		
	
		$this->view->main = FALSE;
		
		
		
	}
	
	
	
	public function indexAction(){
		
		$this->view->main = FALSE;
		
		$chanel = new Chanel_Model_Index();
		
		$storage = new Zend_Auth_Storage_Session();
		$data = $storage->read();
		
		
		$page = 1;
		
		$pagesize = 10;
		
		$arr = array(				
			"page"=> $page,
			"pagesize"=> $pagesize,
			"userid"=> @$data->id,
																
		);
		
		$this->view->list_chanel = $chanel->listItem($arr);
		
		
		if($this->getRequest()->isPost()){
			
			$storage = new Zend_Auth_Storage_Session();
			$data = $storage->read();
			
			$type = $_POST["type"];
			$id = $_POST["id"];
			$status = $_POST["status"];
			
			if (isset($id)){

				$like = new Chanel_Model_Like();				
				$arr = array(
					"userid"=>$data->id,
					"chanelid"=>$id,								
					"status"=>$status,						
					"createdate"=>date('Y-m-d h:i:s',time()),										
				);
				$like->insertLike($arr);
				
				
			}			
			
		}
				
	}
}